Class Strings.DisplayString

A string appearing on the screen.

Can be used for subtitles and "2001, somewhere in Egypt"-style messages.

Uses screen-space coordinates, with x values specifying the number of pixels from the left of the window, and y values specifying the number of pixels from the top of the window.

Since different players will have different resolutions, you should work in terms of percentages where possible, and use ScreenToPercent and PercentToScreen when you need to use screen-space coordinates.

Functions

DisplayString(string, Position[, scale][, color][, translated][, flags]) Create a DisplayString.
DisplayString:GetColor() Get the display string's color
DisplayString:SetColor(color) Set the display string's color
DisplayString:GetKey() Get the string key to use.
DisplayString:SetKey(string) Set the string key to use.
DisplayString:SetScale(scale) Set the scale of the string.
DisplayString:GetScale() Get the scale of the string.
DisplayString:SetPosition(pos) Set the position of the string.
DisplayString:GetPosition() Get the position of the string.
DisplayString:SetFlags(table) Set the display string's flags
DisplayString:SetTranslated(shouldTranslate) Set translated parameter of the string


Functions

DisplayString(string, Position[, scale][, color][, translated][, flags])
Create a DisplayString. For use in ShowString and HideString.

Parameters:

  • string string The string to display or key of the translated string.
  • Position Vec2 of the string in pixel coordinates.
  • scale float size of the string, relative to the default size. Default: 1.0 (optional)
  • color Color the color of the text. Default: white (optional)
  • translated bool If false or omitted, the input string argument will be displayed. If true, the string argument will be the key of a translated string specified in strings.lua. Default: false. (optional)
  • flags table A table of string display options. Can be empty or omitted. The possible values and their effects are:

    TEN.Strings.DisplayStringOption.CENTER: set the horizontal origin point to the center of the string.
    TEN.Strings.DisplayStringOption.RIGHT: set the horizontal origin point to right of the string.
    TEN.Strings.DisplayStringOption.SHADOW: give the string a small shadow.
    TEN.Strings.DisplayStringOption.BLINK: blink the string.
    

    Default: empty (optional)

Returns:

    DisplayString A new DisplayString object.
DisplayString:GetColor()
Get the display string's color

Returns:

    Color a copy of the display string's color
DisplayString:SetColor(color)
Set the display string's color

Parameters:

  • color Color the new color of the display string
DisplayString:GetKey()
Get the string key to use. If isTranslated is true when DisplayString is called, this will be the string key for the translation that will be displayed. If false or omitted, this will be the string that's displayed.()

Returns:

    string the string to use
DisplayString:SetKey(string)
Set the string key to use. If isTranslated is true when DisplayString is called, this will be the string key for the translation that will be displayed. If false or omitted, this will be the string that's displayed.()

Parameters:

  • string string the new key for the display string
DisplayString:SetScale(scale)
Set the scale of the string. ()

Parameters:

  • scale float New scale of the string relative to the default size.
DisplayString:GetScale()
Get the scale of the string. ()

Returns:

    float Scale.
DisplayString:SetPosition(pos)
Set the position of the string. Screen-space coordinates are expected.()

Parameters:

  • pos Vec2 New position in pixel coordinates.
DisplayString:GetPosition()
Get the position of the string. Screen-space coordinates are returned.()

Returns:

    Vec2 pos Position in pixel coordinates.
DisplayString:SetFlags(table)
Set the display string's flags ()

Parameters:

  • table table the new table with display flags options

Usage:

    local varDisplayString = DisplayString('example string', 0, 0, Color(255, 255, 255), false)
    possible values:
    varDisplayString:SetFlags({})
    varDisplayString:SetFlags({ TEN.Strings.DisplayStringOption.SHADOW })
    varDisplayString:SetFlags({ TEN.Strings.DisplayStringOption.CENTER })
    varDisplayString:SetFlags({ TEN.Strings.DisplayStringOption.SHADOW, TEN.Strings.DisplayStringOption.CENTER })
    -- When passing a table to a function, you can omit the parentheses
    varDisplayString:SetFlags{ TEN.Strings.DisplayStringOption.CENTER }
DisplayString:SetTranslated(shouldTranslate)
Set translated parameter of the string

Parameters:

  • shouldTranslate bool if true, the string's key will be used as the key for the translation that will be displayed. If false, the key itself will be displayed
generated by TEN-LDoc (a fork of LDoc 1.4.6)